import React, { Component } from 'react'

export default class Video extends Component {
  //声明状态
  state = {
    url: "http://api.xiaohigh.com/video/random"
  }

  render() {
    return (
      <div>
        <video
          onClick={() => {
            //更新状态
            this.setState({
              url: 'http://api.xiaohigh.com/video/random?t='+Date.now()
            })
          }}
          height="500"
          controls
          src={this.state.url}
        ></video>
      </div>
    )
  }

  //构造方法
  constructor(){
    super();
    console.log('组件实例创建成功~~');
  }

  //组件挂载完毕回调
  componentDidMount(){
    console.log('组件挂载完毕了~~');
  }

  //组件将要卸载
  componentWillUnmount(){
    console.log('组件将要卸载~~');
  }

  //组件更新
  componentDidUpdate(){
    console.log('组件完成更新~~');
  }

}
